package com.cloud.message.controller;

import com.cloud.common.domain.Result;
import com.cloud.controller.BaseController;
import com.cloud.message.entity.SysImMessage;
import com.cloud.message.service.ISysImMessageService;
import com.cloud.utils.ToolUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * IM消息记录
 *
 * @author yzj
 * @since 2024-01-09
 */
@Tag(name = "IM消息记录")
@RestController
@RequestMapping("/message/imInfo")
public class SysImMessageController extends BaseController {

    @Autowired
    private ISysImMessageService sysImMessageService;

    @Operation(summary = "IM消息记录分页")
    @GetMapping("/list")
    public Result list(SysImMessage imMessage) {
        startPage();
        List<SysImMessage> sysImMessageList = sysImMessageService.getSysImMessageList(imMessage);
        return getDataTable(sysImMessageList);
    }

    @Operation(summary = "删除IM消息记录")
    @PostMapping("/remove")
    public Result remove(String ids) {
        List<Long> list = ToolUtils.setIdsToList(ids);
        return toResult(sysImMessageService.removeIds(list));
    }

    @Operation(summary = "获取IM消息记录列表")
    @GetMapping("/getMessageLogs")
    public Result getMessageLogs() {
        return sysImMessageService.getMessageLogs();
    }

}
